package com.action.gulimall.product.web;

import com.action.gulimall.product.service.SkuInfoService;
import com.action.gulimall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

/**
 * @author sl shilun217@qq.com
 * @Deacription 商品sku详情
 * @date 2021/06/23/21:59
 **/
@Controller
public class ItemController {
    @Autowired
    private SkuInfoService skuInfoService;

    /**
     * 展示当前sku的详情
     * @param skuId
     * @return
     */
    @GetMapping("/{skuId}.html")
    public String skuItem(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {

        SkuItemVo vos = skuInfoService.item(skuId);
        model.addAttribute("item",vos);

        return "item";
    }
}
